package com.jkhan.design;

import com.jkhan.design.store.ICommodity;
import com.jkhan.design.store.impl.CardCommodityService;
import com.jkhan.design.store.impl.CouponCommodityService;
import com.jkhan.design.store.impl.GoodsCommodityService;

/**
 * @ClassName StoreFactory
 * @Description StoreFactory
 * @Author hjk
 * @Date 2022/12/27 21:55
 **/
public class StoreFactory {

    public ICommodity getCommodityService(Integer commodityType) {
        if (null == commodityType) {
            return null;
        }
        if (1 == commodityType) {
            return new CouponCommodityService();
        }
        if (2 == commodityType) {
            return new GoodsCommodityService();
        }
        if (3 == commodityType) {
            return new CardCommodityService();
        }
        throw new RuntimeException("不存在的商品服务类型");
    }

}
